var reportSpace=null;
$(function(){
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd'});	
	fillDepartments("depts");
});
/** 填充部门控件 */
function fillDepartments(deptId) {
	var depts = $("#"+deptId);
	$.getJSON('admin/department/department!bytype',
			{
		      "bean.id":"root",
		      "bean.departmentType":"Manufacture"		
			},
			
		function(data, textStatus, jqXHR) {

		$.each(data, function(i, item) {
			var ipt = $("<button type='button' class='btn btn-info' dept='"+item['id']+"'>"+item['name']+"</button>");
			ipt.bind("click",function(){
				departmentClicked($(this).attr("dept"),$(this).html());
			});
			depts.append(ipt);			
		});	
		
	});
}
function departmentClicked(dept,text){
	//alert(text);
}


function showOne(id){
	window.open(reportSpace+"get?bean.id="+id, "swin");
	
	
}

function removeOne(id) {
	if(!confirm("确定要删除此记录?"))return;
    var e = window.event;
    var that = e.srcElement;  
    if(!id){
    	$(that).parent().parent().parent().remove();
    	return;
    }
	$.ajax({
		url : reportSpace+"remove",
		data : "bean.id=" + id,
		success : function() {			
			$(that).parent().parent().parent().remove();
		} 
	});

}
function newOne(){
	window.open(reportSpace+"preselect",'swin');
}